package com.aoxin.service.impl.opm;

import com.aoxin.mapper.SlfPriceHistoryMapper;
import com.aoxin.model.SlfPriceHistory;
import com.aoxin.service.inter.opm.PriceHistoryService;
import com.aoxin.util.ErrorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

@Service
public class PriceHistoryServiceimpl implements PriceHistoryService {

    @Autowired
    private SlfPriceHistoryMapper slfPriceHistoryMapper;

    @Override
    public List<SlfPriceHistory> getSlfPriceHistory(SlfPriceHistory slfPriceHistory) {
        Assert.notNull(slfPriceHistory, String.format(ErrorUtil.PARAMETER_NULL, "slfRecharge"));
        List<SlfPriceHistory> list= slfPriceHistoryMapper.getSlfPriceHistory(slfPriceHistory);
        return list;
    }

    @Override
    public Integer deleteSlfPriceHistory(Integer historyId) {
        Assert.notNull(historyId, String.format(ErrorUtil.PARAMETER_NULL, "historyId"));
        if (historyId !=null ){
            slfPriceHistoryMapper.deleteSlfPriceHistory(historyId);
        }
        return 1;
    }

    @Override
    public Integer deletePriceHistory(List<Integer> historyIds) {
        Assert.notNull(historyIds, String.format(ErrorUtil.PARAMETER_NULL, "historyIds"));
        if (historyIds !=null){

        }
        return null;
    }

    @Override
    public Integer insertSlfPriceHistory(SlfPriceHistory slfPriceHistory) {
        Assert.notNull(slfPriceHistory, String.format(ErrorUtil.PARAMETER_NULL, "slfPriceHistory"));
        if (slfPriceHistory !=null){
            slfPriceHistoryMapper.insertSlfPriceHistory(slfPriceHistory);
        }
        return slfPriceHistory.getHistoryId();
    }

    @Override
    public Integer updateSlfPriceHistory(SlfPriceHistory slfPriceHistory) {
        Assert.notNull(slfPriceHistory, String.format(ErrorUtil.PARAMETER_NULL, "slfPriceHistory"));
        if (slfPriceHistory !=null){
            slfPriceHistoryMapper.updateSlfPriceHistory(slfPriceHistory);
        }
        return slfPriceHistory.getHistoryId();
    }


}
